/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.ws.client.field;

import java.io.FileOutputStream;
import java.math.BigInteger;
import java.util.Arrays;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;

import net.bioteam.appweb.TestConfig;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.A_selection;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.Afloat;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.Aint;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.ExecuteProgram;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.ExecuteProgramResponse;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.FileType;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.FileTypeSequence_type0;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetFile;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetFileResponse;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetJobFileAsZip;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetJobFileAsZipResponse;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetJobStatus;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.GetJobStatusResponse;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.JobStatusType;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.ListFiles;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.ListFilesResponse;
import net.bioteam.appweb.ws.client.field.ProgramwsStub.Multi_selection;

import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;

import junit.framework.TestCase;

public class FieldTest extends TestCase
{

	public FieldTest()
	{
		
	}
	public FieldTest(String name)
	{
		super(name);
	}

	net.bioteam.appweb.ws.client.field.ProgramwsStub stub;
	@Override
	protected void setUp() throws Exception
	{

			stub = new net.bioteam.appweb.ws.client.field.ProgramwsStub(null, TestConfig.serviceURL);

		ServiceClient sc = stub._getServiceClient();

		sc.engageModule("rampart");
		Options options = sc.getOptions();
		options.setUserName("test");
		options.setPassword("test");
		options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
	}
	protected void tearDown() throws Exception
	{
		super.tearDown();
	}
	public void testexecuteProgram() throws java.lang.Exception
	{

		ExecuteProgram program = new ExecuteProgram();
		program.setProgramName("field");
		program.setStr("str1");
		Aint i=new Aint();
		i.setAint(new BigInteger("7"));
		program.setAint(i);
		program.setAint1(new BigInteger("6"));
		program.setAfloat1(5.5);
		program.setAswitch(true);
		program.setBswitch(false);
		program.setA_selection(A_selection.value1);
		Multi_selection ss[]={Multi_selection.valuex1, Multi_selection.valuex2};
		program.setMulti_selection(ss);
		program.set_cluster(-1);
		FileDataSource src = new FileDataSource("misc/seq.txt");
		DataHandler dh=new DataHandler(src);
		FileType ftype=new FileType();
		FileTypeSequence_type0 file=new FileTypeSequence_type0();
		file.setFileName("seq.txt");
		file.setBinaryData(dh);
		ftype.setFileTypeSequence_type0(file);
		
		program.set_file1(ftype);
		

		

		ExecuteProgramResponse resp = stub.executeProgram(program);
		String jobid = resp.getJobid();
		System.out.println("jobid is " + resp.getJobid());
		System.out.println("workdir is " + resp.getWorkdir());
		
		
	}

}
